//
//  LocalMusicViewController.m
//  DolphinMusic
//
//  Created by dllo on 15/3/21.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "LocalMusicViewController.h"



#import "Flag.h"
#import "LocalModel.h"

#import "MyDownLoadViewController.h"
#import "MyFMViewController.h"
#import "RecentPlayViewController.h"
#import "MyCollectionViewController.h"


@interface LocalMusicViewController ()

@end

@implementation LocalMusicViewController

- (void)dealloc
{
    [super dealloc];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    
/***************** 下面勿动 *****************/
    self.buttonView.frame = self.localButton.frame;
    [self.netButton addTarget:self action:@selector(netMusicButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.FMButton addTarget:self action:@selector(FMButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.searchButton addTarget:self action:@selector(searchButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.settingButton addTarget:self action:@selector(settingButtonAction:) forControlEvents:UIControlEventTouchUpInside];
/****************** 上面勿动 ********************/
    
    UIWindow *window = [[[UIApplication sharedApplication] windows] firstObject];
    PlayView *playView = (PlayView*)[window viewWithTag:10001];
    playView.target = self.navigationController;
    
    
    self.view.backgroundColor = [UIColor whiteColor];
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 64, VIEW_WIDTH, VIEW_HEIGHT - 64)];
    imageView.image = [UIImage imageNamed:@"localBG.jpg"];
    [self.view addSubview:imageView];
    [imageView release];

    CGFloat width1 = VIEW_WIDTH / 3 / 3;
    
    LocalModel *model1 = [[LocalModel alloc] initWithFrame:CGRectMake(width1, 100, width1 * 3, width1 * 3) image:@"xiazai111" labelText:@"我的下载"];
    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(modelButtonAction1)];
    [model1.view addGestureRecognizer:tap1];
    [tap1 release];
    [self.view addSubview:model1];
    
    LocalModel *model2 = [[LocalModel alloc] initWithFrame:CGRectMake(width1 * 2 + width1 * 3, 100, width1 * 3, width1 * 3) image:@"shoucang111" labelText:@"我的收藏"];
    UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(modelButtonAction2)];
    [model2.view addGestureRecognizer:tap2];
    [tap2 release];
    [self.view addSubview:model2];

    LocalModel *model3 = [[LocalModel alloc] initWithFrame:CGRectMake(width1, 100 + model1.frame.size.height + 36, width1 * 3, width1 * 3) image:@"diantai111" labelText:@"我的电台"];
    UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(modelButtonAction3)];
    [model3.view addGestureRecognizer:tap3];
    [tap3 release];
    [self.view addSubview:model3];

    LocalModel *model4 = [[LocalModel alloc] initWithFrame:CGRectMake(width1 * 2 + width1 * 3, model3.frame.origin.y, width1 * 3, width1 * 3) image:@"zuijin111" labelText:@"最近播放"];
    UITapGestureRecognizer *tap4 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(modelButtonAction4)];
    [model4.view addGestureRecognizer:tap4];
    [tap4 release];
    [self.view addSubview:model4];

    
}
- (void)viewWillAppear:(BOOL)animated
{
    UIWindow *window = [[UIApplication sharedApplication] keyWindow];
    
    UIButton *button = (UIButton *)[window viewWithTag:1000];
    button.hidden = NO;
  
}


- (void)modelButtonAction1
{
    MyDownLoadViewController *downLoadVC = [[MyDownLoadViewController alloc] init];
    [self.navigationController pushViewController:downLoadVC animated:YES];
    [downLoadVC release];
}

- (void)modelButtonAction2
{
    MyCollectionViewController *collectionVC = [[MyCollectionViewController alloc] init];
    [self.navigationController pushViewController:collectionVC animated:YES];
    [collectionVC release];
}

- (void)modelButtonAction3
{
    MyFMViewController *FMVC = [[MyFMViewController alloc] init];
    [self.navigationController pushViewController:FMVC animated:YES];
    [FMVC release];
}

- (void)modelButtonAction4
{
    RecentPlayViewController *recentPlayVC = [[RecentPlayViewController alloc] init];
    [self.navigationController pushViewController:recentPlayVC animated:YES];
    [recentPlayVC release];
}

/***************** 下面勿动 *****************/
- (void)FMButtonAction:(UIButton *)button
{
    [self.tabBarController setSelectedIndex:2];
}
- (void)netMusicButtonAction:(UIButton *)button
{
    [self.tabBarController setSelectedIndex:1];
}
- (void)searchButtonAction:(UIButton *)button
{
    Flag *flag = [Flag shareInstance];
    flag.flag = 0;
    [self.tabBarController setSelectedIndex:3];
}
- (void)settingButtonAction:(UIButton *)button
{
    [self.tabBarController setSelectedIndex:4];
}
/************************ 上面勿动 ************************/





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
